add perl xs bindings with cpan packaging support#28
Merged
MuriloChianfa merged 2 commits intomainfrom Jan 31, 2026
Merged
Conversation
Closed
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
MuriloChianfa
added a commit
that referenced
this pull request
Jan 31, 2026
Resolved conflicts in: - .github/workflows/ci.yml: Added Lua, Perl, PHP, and Python bindings tests - CMakeLists.txt: Combined Lua, Perl, PHP, and Python wrapper options - docker/README.md: Documented all language binding containers - scripts/docker-build.sh: Added support for all binding images This merge brings in the Perl (#28), Python (#27), and PHP (#26) bindings alongside the existing Lua bindings work.
MuriloChianfa
added a commit
that referenced
this pull request
Jan 31, 2026
Resolved conflicts in: - .github/workflows/ci.yml: Added C#, Lua, Perl, PHP, and Python bindings tests - CMakeLists.txt: Combined C#, Lua, Perl, PHP, and Python wrapper options - docker/README.md: Documented all language binding containers - scripts/docker-build.sh: Added support for all binding images This merge brings in the Lua (#29), Perl (#28), Python (#27), and PHP (#26) bindings alongside the existing C# bindings work.
MuriloChianfa
added a commit
that referenced
this pull request
Jan 31, 2026
Resolved conflicts in: - .github/workflows/ci.yml: Added Java, C#, Lua, Perl, PHP, and Python bindings tests - CMakeLists.txt: Combined Java, C#, Lua, Perl, PHP, and Python wrapper options - docker/README.md: Documented all language binding containers - scripts/docker-build.sh: Added support for all binding images This merge brings in the C# (#31), Lua (#29), Perl (#28), Python (#27), and PHP (#26) bindings alongside the existing Java bindings work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds comprehensive Perl bindings for the liblpm C library via XS (eXternal Subroutine interface), providing high-performance longest prefix match (LPM) routing table operations for Perl applications. The bindings deliver near-native C performance with an idiomatic Perl API, automatic memory management, and full POD documentation.
Type of Change
Related Issues
Closes #
Motivation and Context
Perl is widely used in network automation, system administration, and DevOps tooling where efficient IP routing lookups are essential. While CPAN has various networking modules, high-performance LPM implementations are scarce. This implementation provides:
This enables Perl developers to leverage liblpm's high-performance routing capabilities in scripts, network tools, and production systems.
Changes Made
Core Implementation
XS Bindings (
LPM.xs): 475 lines of C/XS glue codeinet_ptoncroak()Perl Module (
lib/Net/LPM.pm): 452 lines including PODnew_ipv4(),new_ipv6()insert(),delete(),lookup(),lookup_batch()is_ipv4(),is_ipv6(),print_stats(),version()LPM_INVALID_NEXT_HOPType Mapping (
typemap): Custom XS type conversionsBuild System
LIBLPM_INC,LIBLPM_LIB)testv,valgrind,docs,devTesting & Quality
Comprehensive Test Suite (6 test files, 100+ test cases):
t/00-load.t: Module loading and basic sanity checkst/01-ipv4-basic.t: IPv4 operations, longest prefix match, edge casest/02-ipv6-basic.t: IPv6 operations, various address formatst/03-batch.t: Batch lookup correctness and performancet/04-memory.t: Memory management and reference countingt/05-errors.t: Error handling and invalid inputsExample Script (
examples/basic_example.pl): 184 linesDocumentation
README.md (289 lines):
POD Documentation (200+ lines in LPM.pm):
perldoc Net::LPMTesting
Test Environment
Tests Performed
make test)make valgrind)perl -MNet::LPM -e 'print Net::LPM->version()')podchecker lib/Net/LPM.pm)Test Output
Memory Leak Check
Performance Impact
Performance Characteristics
XS Overhead: The Perl/C boundary adds approximately 5-20ns per call. To minimize overhead:
Batch Operations: Use
lookup_batch()for multiple addressesObject Reuse: Avoid frequent create/destroy cycles
Benchmark Results
Key Takeaway: Batch operations reduce per-lookup cost by 2-3x, making them ideal for network packet processing, log analysis, and bulk IP address classification.
Documentation
POD Documentation Features:
perldoc Net::LPMCode Quality
XS Code Quality:
Perl Code Quality:
Breaking Changes
This is a new feature addition with no impact on existing C library or other language bindings.
Additional Notes
Key Features
Package Structure
Files Changed
CPAN Distribution
Package is ready for CPAN upload:
Platform Support
Perl Versions:
Checklist
perl Makefile.PL && make)Reviewer Notes
Areas for Review
XS Code Safety: Review memory management in batch operations
API Design: Is the Perl API idiomatic and intuitive?
Build System: Makefile.PL library detection logic
Documentation: POD completeness and accuracy
Test Coverage: Are edge cases adequately tested?
CPAN Readiness: Package metadata and distribution
Testing Instructions
Development Workflow
Performance Testing
Future Enhancements (Out of Scope)